﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp
{
    public partial class trip1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null)
                this.user.Text = "nie zalogowany";
            else
                this.user.Text = (string)Session["username"];

            IDAO li = new MyLinq();

            if (Request.QueryString["id"] != null)
            {
                trip tr = li.getTrip(int.Parse(Request.QueryString["id"]));
                if (tr.status != 5)
                {
                    this.country.Text = tr.country.name;
                    this.name.Text = tr.name;
                    this.description.Text = tr.description;
                    this.start_date.Text = tr.start_date.ToString();
                    this.end_date.Text = tr.end_date.ToString();
                    this.places_count.Text = tr.places_count.ToString();
                    this.price.Text = tr.price.ToString();

                    this.GridView1.DataSource = tr.attractions;
                    this.GridView1.DataBind();
                }
                else{
                    this.name.Text = "Wycieczka zawieszona";
                }

            }
        }

        protected void zarezerwuj_Click(object sender, EventArgs e)
        {
            IDAO a = new MyData();
            a.addReservation(int.Parse(Request.QueryString["id"]), (int)Session["person_id"], -1, 1);
            //a.addReservation(int.Parse(Request.QueryString["id"]),(int)Session["person_id"],-1, 5);
        }
    }
}
